<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
?>
<div class="row">
    <div class="col-xs-12 posi-rela">
        <div class="list_carousel frame" id="basic">
            <div id="slider-wrap">
                <ul id="foo1" style="width:<?php echo 355 * count($event) ?>px">
                    <?php if(isset($event)) : ?>
                    	<?php foreach($event as $value) : ?>
		                    <li class="animation">
		                    	<!-- <a href=""></a> -->

                                                        <a  class="show-event-ajax a-animation"   data-href="#modal-details" data-remote-target="#modal-details .modal-body" data-load-remote="<?php echo Yii::app()->createAbsoluteUrl('event/views', array('id' => $value['id'])); ?>">
                                 <!--<a href="#myModal" role="button" class="a-animation" data-toggle="modal" data-load-remote="<?php echo Yii::app()->createAbsoluteUrl('event/views',array('id' => $value['id'])); ?>" data-remote-target="#myModal .modal-body">-->
		                        <div class="item-image-wrap">
		                            <img src="<?php echo Yii::app()->baseUrl; ?>/timthumb.php?src=<?php echo Yii::app()->baseUrl; ?>/data/image/event/<?php echo $value['event']['cover_image']; ?>&h=213&w=320" alt=""/>

		                        </div>
		                        <div class="view-item">

		                            <h3>
		                            	<?php if(strlen($value['main_title']) > 25) : ?>
		                            		<?php echo substr($value['main_title'],0,strrpos(substr($value['main_title'],0,20)," ")) . ' ...'; ?>
		                            	<?php else :  ?>
		                            		<?php echo $value['main_title']; ?>
		                            	<?php endif;?>
		                            </h3>
                                    <div class="author">
                                    	<?php if(strlen($value['sub_title']) > 70) : ?>
                                    		<?php echo substr($value['sub_title'],0,strrpos(substr($value['sub_title'],0,65)," ")) . ' ...'; ?>

		                            	<?php else :  ?>
		                            		<?php echo $value['sub_title']; ?>
		                            	<?php endif;?>
                                    	<?php // echo $value['sub_title']; ?>
                                    </div>
		                            <div class="time"><p><?php echo date_format(new DateTime($value['event']['start_time']),'h:i A'); ?>, <?php echo date_format(new DateTime($value['event']['start_date']),'d - m , Y'); ?></p></div>
		                            <div class="address">
		                                <p>
		                                <?php $location =  $value['location'] . ' , ' . $value['address']; ?>
		                                <?php if(strlen($location) > 40) : ?>
                                    		<?php echo substr($location,0,strrpos(substr($location,0,37)," ")) . ' ...'; ?>
		                            	<?php else :  ?>
		                            		<?php echo $value['location']; ?> , <?php echo $value['address']; ?>
		                            	<?php endif;?>
		                                	<?php // echo $value['location']; ?>
		                                </p>
		                            </div>
		                            <div class="bt-item num-view-ctn">
		                            	<div class="num-people pull-right num-view">
		                            		<span class="views-num"><?php echo number_format($value->event['num_view']); ?></span>
		                            		<span class="icon-views-num"></span>
		                            	</div>
		                            	<?php
	                                		// $number_book = MyFunctionCustom::GetBookevent($value['event_id']);
	                                		// if ($number_book > 0) :
		                                ?>
		                                <!-- <div class="num-people pull-right"> -->
		                                    <!-- <span style="visibility:hidden"> <?php // echo $number_book; ?>  </span> <?php // echo Yii::t('lang','booked_text') ?> -->

		                                <!-- </div> -->
		                                <?php // else : ?>
			                                <!-- <div class="num-people pull-right" style="visibility:hidden"> -->

			                                   <!--  <span> <?php // echo $number_book; ?>  </span> <?php // echo Yii::t('lang','booked_text') ?> -->

			                                <!-- </div> -->
		                                <?php // endif; ?>
		                            </div>
		                        </div>

		                        </a>
		                    </li>
                    	<?php endforeach; ?>
                 	<?php endif; ?>

                </ul>
            </div>
<!--                <button class="prev"><</button>
    <button  class="next">></button>-->
                <div class="clearfix"></div>


            </div>

        </div>
    </div>
<script type="text/javascript">
$(function(){
	var date = <?php if (isset($date)){
    	echo CJSON::encode(date('d-m-Y', strtotime($date)));
    	}
    	else echo CJSON::encode("0");
    ?>;
          $('#dim-block').bind('touchend',function(){
              $('#datepicker').datepicker( "hide" );
          });   
    $('#datepicker').datepicker({
        inline: true,
        // changeMonth: true,
        showOtherMonths: true,
        selectOtherMonths: true,
        dateFormat: 'dd-mm-yy',
        beforeShow:function(){
            $('#dim-block').show();
        },
        onClose:function(){
            $('#dim-block').hide();
        },
        // setDate: 0,
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        onSelect: function (dateText, inst) {
            $(this).parent('form').submit();
        }
        }).datepicker("setDate", date);
});
</script>